﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TaoPortal.BusinessLogic.Extensions;
using TaoPortal.BusinessLogic.Repository;
using TaoPortal.Entity;


namespace TaoPortal.Areas.Admin.Models
{
    public class MsgModel : BaseModel
    {
        public string MsgType { get; set; }
        public string Sender { get; set; }
        public string MsgBody { get; set; }
        public DateTime? StartTime { get; set; }
        public DateTime? EndTime { get; set; }
        public string ParentID { get; set; }
        public int TotalCount { get; set; }

        public PagedList<TP_SysMsg> GetSysMsgList()
        {
            var rp = new SystemRepository();
            var data = rp.GetSysMsgList(MsgType, Sender, MsgBody, null, StartTime, EndTime, PageIndex, PageSize);
            return data;
        }

        public void Delete(string ids)
        {
            List<string> idList = ids.Split(',').ToList();
            var rp = new SystemRepository();
            rp.DeleteSysLog(idList);
        }

        public PagedList<TP_SysMsg> GetSysMsgByParentID(string parentId)
        {
            PageSize = 100;
            var rp = new SystemRepository();
            var data = rp.GetSysMsgList(MsgType, Sender, MsgBody, parentId, StartTime, EndTime, PageIndex, PageSize);
            return data;
        } 

    }
}